var vm = new Vue({
  el : '#app',
  extends: CommonTools,
  
  data : function() {
    return {
    	gTeacher:{
      },
      password:'',
      password1:'',
    }
    
  },
  
  filters: {
    /**
     * 状态名称
     */
    stateName(state) {
      for (var i = 0; i < vm.states.length; ++i) {
        if (vm.states[i].value == state) {
          return vm.states[i].label;
        }
      }
      return state;
    },
    
  },
  
 /* computed: {
  readonly: function(){
      return this.activity && (this.activity.state != 'uncommit');
    },
    
    
  },*/
  
  methods: {
    
    /**
     * 重新加载单据
     */
	  reload(){
	      var self = this;
	      var id = JSON.parse(sessionStorage.user).id;
	      var url = "../../gTeacherController.do?get&id=" 
	        + (id?id:'');
	      this.get(url).then((data) => {       
	        self.gTeacher = data;
	      }).catch(err => {
	        this.showError(err);
	      });
	    },
    
    /**
     * 保存操作
     */
    onSave() {
        var self = this;
        return self.doSave();
      },

    /**
     * 保存
     */
    doSave(){
      var self = this;
      var url = '../../gTeacherController.do?doAdd2';
      //self.gTeacher.id=JSON.parse(sessionStorage.user).id;
      if(self.password != self.password1){
    	  $.toast("两次密码输入不一致！", "text");
    	  return false;
      }else{
    	  self.gTeacher.tpassword=self.password;
    	  self.post(url, self.gTeacher).then(() => {
    		  self.showMsg('操作成功！', function() {
    			  self.goback();
    		  });
    	  }).catch(err => {
    		  self.showError(err);
    	  });
      }
    },
    
    
    goback(){
      history.back();
    },
    
  },
  
  created() {
    this.reload();
  },
  
});
